package com.cn.lf.wx;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.cn.lf.wx.dacs.bussiness.author.dao.HisMapper;
import com.cn.lf.wx.dacs.bussiness.author.serviceImpl.HisServiceImpl;
import com.cn.lf.wx.dacs.bussiness.author.utils.Main;
import com.cn.ym.log.Log;

@Component
public class ScheduledCompent {
	@Autowired
	private HisServiceImpl hisService;
	
	@Async
	@Scheduled(cron = "0 0 0 15 * ?")
	public void watchEmrSchedul() throws Exception {		
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
		SimpleDateFormat sqlsimp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String StringDate = this.hisService.selectByDate();
		Date date = sqlsimp.parse(StringDate);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MONTH, -1);
		String endtime = simpleDateFormat.format(date)+"000000";
		String starttime = simpleDateFormat.format(calendar.getTime())+"000000";
		Log.info("定时器---start"+starttime+"---endtime--"+endtime);
		new Main().main(starttime,endtime);
	}
	
}